<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CartController extends Controller
{
	
	
	//显示购物车页面详细信息
	public function cart(){
		 $shopcars = DB::table('shopcar')
					->join('goods','goods.gid','=','shopcar.gid')
					->paginate();

		return view('home.cart',['shopcars'=>$shopcars]);
		
	}
	
	//删除购物车商品操作
	public function delete(Request $request){
		
		//接受用户id
		$carid = $request->input('carid');

		//删除操作
		$result = DB::table('shopcar')->where('carid','=',$carid)->delete();
		
		if($result){
			echo 1;
		}else{
			echo 0;
		}
	}
		
	
	//显示购物车结算中心用户收货地址
	public function settle(){
		$addresss = DB::table('address')->paginate(3);
		return view('home.cart.settle',['addresss'=>$addresss]);
		
	}
	
	//显示购物车收银台
	public function cashier(){
		
		return view('home.cart.cashier');
	}
}
